package cn.wolfcode.crm.web.controller;

import cn.wolfcode.crm.domain.ClientPlant;
import cn.wolfcode.crm.query.ClientPlantQueryObject;
import cn.wolfcode.crm.service.IClientPlantService;
import cn.wolfcode.crm.util.JsonResult;
import cn.wolfcode.crm.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("clientPlant")
public class ClientPlantController {
@Autowired
    private IClientPlantService service;

@RequestMapping("")
    public String index(){
    return "/clientPlant/list";
}

@RequestMapping("list")
@ResponseBody
    public PageResult list(ClientPlantQueryObject qo){
        return service.query(qo);
}



    @RequestMapping("positive")
    @ResponseBody
    private JsonResult positive(Long id) {
        JsonResult jsonResult = new JsonResult();
        try {
            service.positive(id);
        } catch (Exception e) {
            jsonResult.setMsg(e.getMessage());
        }
        return jsonResult;
    }


    @RequestMapping("planmovesource")
    @ResponseBody
    private JsonResult planmovesource(Long id) {
        JsonResult jsonResult = new JsonResult();
        try {
            service.planmovesource(id);
        } catch (Exception e) {
            jsonResult.setMsg(e.getMessage());
        }
        return jsonResult;
    }

    @RequestMapping("moveInSource")
    @ResponseBody
    private JsonResult moveInSource(ClientPlant cp) {
        JsonResult jsonResult = new JsonResult();
        try {
            service.moveInSource(cp);
        } catch (Exception e) {
            jsonResult.setMsg(e.getMessage());
        }
        return jsonResult;
    }

}
